feat(config): generic resource detector plugin loading for declarative config#5129
Draft
MikeGoldsmith wants to merge 3 commits intoopen-telemetry:mainfrom
Draft
Conversation
ExperimentalResourceDetector is changed from @DataClass to TypeAlias = dict[str, Any] in models.py, preserving unknown detector names as dict keys through the config pipeline. _run_detectors() now iterates the dict's key-value pairs directly via _RESOURCE_DETECTOR_REGISTRY. Known names (service, host, process) are bootstrapped directly from the SDK. Unknown names — including container and custom plugin detectors — are loaded via the opentelemetry_resource_detector entry point group, matching the spec's PluginComponentProvider mechanism. The container detector behavior changes from warning-when-missing to raising ConfigurationError, consistent with the fail-fast approach agreed on in the issue discussion. Assisted-by: Claude Opus 4.6
22 tasks
_run_detectors() now iterates detector config dicts directly via _RESOURCE_DETECTOR_REGISTRY. Known names (service, host, process) are bootstrapped directly from the SDK. Unknown names — including container and custom plugin detectors — are loaded via the opentelemetry_resource_detector entry point group, matching the spec's PluginComponentProvider mechanism. The generated models are unchanged. Python dataclasses don't enforce field types at runtime, so the detectors list naturally accepts raw dicts (from the YAML loader) alongside typed ExperimentalResourceDetector instances. This preserves unknown plugin names as dict keys without diverging from codegen. The container detector behavior changes from warning-when-missing to raising ConfigurationError, consistent with the fail-fast approach agreed on in the issue discussion. Assisted-by: Claude Opus 4.6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends resource detector support in declarative file configuration to handle custom (plugin) detectors, matching the spec's PluginComponentProvider mechanism.
Solution
_run_detectors()now iterates detector config dicts directly via_RESOURCE_DETECTOR_REGISTRY:service,host,process) are bootstrapped directly from the SDKcontainerand custom plugin detectors — are loaded viaload_entry_point("opentelemetry_resource_detector", name)The generated models are unchanged. Python dataclasses don't enforce field types at runtime, so the
detectorslist naturally accepts raw dicts (from the YAML loader) alongside typedExperimentalResourceDetectorinstances. This preserves unknown plugin names as dict keys without diverging from codegen.Behavior change
The
containerdetector previously logged a warning when the contrib package was not installed. It now raisesConfigurationError, consistent with the fail-fast approach for declarative config (as discussed in the issue).Custom detector example
Closes #5053